package src.com.fd.servlet;


import src.com.fd.dao.JdbcImpl;
import src.com.fd.dao.Jdbcdao;
import src.com.fd.pojo.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet("/selectAll")
public class SelectServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response){
        response.setContentType("text/html;charset=UTF-8");
        Jdbcdao jdbcdao = new JdbcImpl();
        ArrayList<User> users = jdbcdao.selectAll();
        request.setAttribute("users",users);
        try {
            request.getRequestDispatcher("login.jsp").forward(request,response);
            return;
        } catch (ServletException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response){
        doGet(request,response);
    }
}
